<h1><span></span><?= lang('label_menu_link_purshases') ?></h1>

<ul class="breadcrumb">
    <li><a href="<?= base_url() ?>"><?= lang('label_home') ?></a></li>
    <li><a href="<?= base_url('user/profile') ?>"><?= lang('label_profile') ?></a></li>
    <li><?= lang('label_menu_link_purshases') ?></li>
</ul>
<div class="page">
    <?php $this->load->view('template/default/user/top') ?>
    <?php $this->load->view('template/default/user/side') ?>
    <div class="profile_page">
        <h2 class="profile_page_title"><?= lang('label_profile') ?> &raquo; <strong><?= lang('label_menu_link_purshases') ?></strong></h2>

        <?php if ($data) { ?>
            <table id="tablestyle">
                <thead>
                    <tr>
                        <th><?= lang('label_inv_num') ?></th>
                        <th><?= lang('label_products') ?></th>
                        <th><?= lang('label_type') ?></th>
                        <th><?= lang('label_operation') ?></th>
                    </tr>
                </thead>

                <tbody>
                    <?php foreach ($data as $deal) { ?>
                        <tr>
                            <td><a href="<?= base_url("invoicies/show/$deal->inv_num") ?>" ><?= strtoupper($deal->inv_num) ?></a></td>
                            <td><?php
                                $prod = get_item_data($deal->item_id);
                                if (isset($prod['id']) && isset($prod['title'])) {
                                    ?>
                                    <a href="<?= base_url('products/view/' . $prod['id']) ?>" target="_blank"><?= $prod['title'] ?></a>
                                <?php } ?>
                            </td>
                            <td><?=
                                lang('label_deal_need_' . strtolower($deal->type));
                                if ($deal->sent == 'YES')
                                    echo '<br />(' . lang('label_product_sent') . ')'
                                    ?></td>
                            <td><a href="<?= base_url("user/showdeal/$deal->item_id/$deal->inv_num") ?>"><?= lang('label_details') ?></a>
                                <?php if ($deal->type == 'SEND') { ?>
                                <?php if($deal->sent == 'YES'){ ?>
                                    <span> | <a href="<?= base_url("user/shipingdetails/$deal->id/$deal->inv_num") ?>"><?= lang('label_shiping_details') ?></a> </span>
                                <?php } ?>
                                    <?php if($deal->user_accept == 'NO' && $deal->sent == 'YES'){ ?>
                                        <span> | <a href="<?= base_url("user/delivers/$deal->id/$deal->inv_num") ?>"><?= lang('label_product_deliverd') ?></a> </span>
                                    <?php } ?>
                                        <span> | <a href="<?= base_url("cases/add/$deal->item_id/$deal->inv_num") ?>"><?= lang('label_add_resloution') ?></a></span>
                                <?php } ?>
                            </td>
                        </tr>
                    <?php } ?>
                </tbody>
            </table>
        <?php } else { ?>
            <div class="unsaved">
                <img src="<?php echo str_replace('/index.php', '', $_SERVER['SCRIPT_NAME']) ?>/<?php echo APPPATH ?>views/<?php echo $this->themes->Cms_themes() ?>/images/unsaved.png" alt="" />
                <br /><?= lang('message_no_purshases_items') ?>
            </div>
            <br /><br /><br /><br />
        <?php } ?>

    </div>
</div>